package backend

import "blog/models"

type CategoryController struct {
	baseController
}

func (c *CategoryController) Index() {
	c.display()
}

func (c *CategoryController) Create() {
	var model models.Category
	c.Data["model"] = model
	c.display()
}

func (c *CategoryController) Edit() {
	id, err := c.GetInt("id", -1)
	if err != nil {
		c.notFound("错误的id")
	}
	category, err := models.GetById(models.CategoryTable(), id)
	if err != nil {
		c.notFound("错误的id")
	}
	c.Data["model"] = category
	c.display()
}
